package org.meb.commons;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {

	public static String format(Date date, String pattern) {
		return format(date, new SimpleDateFormat(pattern), null);
	}

	public static String format(Date date, DateFormat fmt) {
		return format(date, fmt, null);
	}

	public static String format(Date date, String pattern, String ifDateNull) {
		return format(date, new SimpleDateFormat(pattern), ifDateNull);
	}

	public static String format(Date date, DateFormat fmt, String ifDateNull) {
		return date == null ? ifDateNull : fmt.format(date);
	}
}
